package com.timoon.sample.service.homepage;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.timoon.sample.dao.ProductPropertyDAO;
import com.timoon.sample.dao.model.ProductProperty;
import com.timoon.sample.dao.model.ProductPropertyExample;
import com.timoon.webcomponent.utility.sift.jd.JdSiftModel;
import com.timoon.webcomponent.utility.sift.jd.JdSiftService;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */

@Service(value="sample.jdSiftService")
public class ProductServiceImpl implements JdSiftService {

	@Resource
	private ProductPropertyDAO productPropertyDAOImpl;
	
	@Override
	public List<JdSiftModel> getPropertyListByGoodsId(final Integer id) {
		// TODO Auto-generated method stub
		
		List<JdSiftModel> models=new ArrayList<>();
		
		List<ProductProperty> pps=this.productPropertyDAOImpl.selectByExample(new ProductPropertyExample(){{
			this.createCriteria().andProductIdEqualTo(id);
		}});
		
		for(ProductProperty pp:pps){
			JdSiftModel model=new JdSiftModel();
			
			model.setKey(pp.getId());
			model.setTitle(pp.getValue());
		}
		
		return models;
	}

}
